/*     */ package org.apache.commons.dbutils;
/*     */ 
/*     */ import java.sql.ResultSet;
/*     */ import java.sql.ResultSetMetaData;
/*     */ import java.sql.SQLException;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import java.util.Map.Entry;
/*     */ 
/*     */ public class MyBasicRowProcessor extends BasicRowProcessor
/*     */ {
/*     */   public Map<String, Object> toMap(ResultSet rs)
/*     */     throws SQLException
/*     */   {
/*  14 */     Map result = new CaseInsensitiveHashMap();
/*  15 */     ResultSetMetaData rsmd = rs.getMetaData();
/*  16 */     int cols = rsmd.getColumnCount();
/*     */ 
/*  18 */     for (int i = 1; i <= cols; i++) {
/*  19 */       Object obj = rs.getObject(i);
/*  20 */       if (obj == null) {
/*  21 */         result.put(rsmd.getColumnLabel(i), "");
/*     */       }
/*  25 */       else if ((obj instanceof Date)) {
/*  26 */         SimpleDateFormat dateformat = new SimpleDateFormat(
/*  27 */           "yyyy-MM-dd HH:mm:ss");
/*  28 */         result.put(rsmd.getColumnLabel(i), 
/*  29 */           dateformat.format((Date)obj));
/*     */       }
/*     */       else
/*     */       {
/*  33 */         result.put(rsmd.getColumnLabel(i), rs.getObject(i));
/*     */       }
/*     */     }
/*  36 */     return result;
/*     */   }
/*     */ 
/*     */   private static class CaseInsensitiveHashMap extends HashMap<String, Object>
/*     */   {
/*  53 */     private final Map<String, String> lowerCaseMap = new HashMap();
/*     */     private static final long serialVersionUID = -2848100435296897392L;
/*     */ 
/*     */     public boolean containsKey(Object key)
/*     */     {
/*  65 */       Object realKey = this.lowerCaseMap.get(key.toString().toLowerCase());
/*  66 */       return super.containsKey(realKey);
/*     */     }
/*     */ 
/*     */     public Object get(Object key)
/*     */     {
/*  76 */       Object realKey = this.lowerCaseMap.get(key.toString().toLowerCase());
/*  77 */       return super.get(realKey);
/*     */     }
/*     */ 
/*     */     public Object put(String key, Object value)
/*     */     {
/*  89 */       Object oldKey = this.lowerCaseMap.put(key.toLowerCase(), key);
/*  90 */       Object oldValue = super.remove(oldKey);
/*  91 */       super.put(key, value);
/*  92 */       return oldValue;
/*     */     }
/*     */ 
/*     */     public void putAll(Map<? extends String, ?> m)
/*     */     {
/*  98 */       for (Map.Entry entry : m.entrySet()) {
/*  99 */         String key = (String)entry.getKey();
/* 100 */         Object value = entry.getValue();
/* 101 */         put(key, value);
/*     */       }
/*     */     }
/*     */ 
/*     */     public Object remove(Object key)
/*     */     {
/* 108 */       Object realKey = this.lowerCaseMap.remove(key.toString().toLowerCase());
/* 109 */       return super.remove(realKey);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     org.apache.commons.dbutils.MyBasicRowProcessor
 * JD-Core Version:    0.6.1
 */